﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Configuration;

public partial class ReporteImpresion : System.Web.UI.Page
{
    private static int folio = 0;
    private static AppSettingsReader settings = new AppSettingsReader();
    private static int tipoReporte = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.IsPostBack == false)
        {
            folio = int.Parse(this.Request.QueryString["id"]);
            tipoReporte = int.Parse(this.Request.QueryString["tipo"]);
            btnGenera_Click(null, null);
        }
    }
    protected void btnGenera_Click(object sender, EventArgs e)
    {
        switch (tipoReporte)
        {
            case 1:
                reporteSolicitudEmpleo();
                break;
            default:
                break;
        }
    }

    private void reporteSolicitudEmpleo()
    {
        string usuarioReporting = (string)settings.GetValue("UsuarioReporting", typeof(string));
        string passwordReporting = (string)settings.GetValue("PasswordReporting", typeof(string));
        string dominioReporting = (string)settings.GetValue("DominioReporting", typeof(string));
        string servidorReporting = (string)settings.GetValue("ServidorReporting", typeof(string));
        string reportPath = (string)settings.GetValue("ReportPath", typeof(string));

        ReportParameter[] parameters = new ReportParameter[1];
        parameters[0] = new ReportParameter("idSolicitud", folio.ToString());
        ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
        ReportViewer1.ServerReport.ReportServerCredentials =
            new ReportViewerCredentials(usuarioReporting, passwordReporting, dominioReporting);
        ReportViewer1.ServerReport.ReportServerUrl = new Uri(servidorReporting);
        ReportViewer1.ServerReport.ReportPath = reportPath;
        ReportViewer1.ServerReport.SetParameters(parameters);
        ReportViewer1.ServerReport.Refresh();
    }
}